<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加</title>
    <#assign base=request.contextPath  />
    <base id="base" href="${base}">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${base}/static/win10/component/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${base}/static/style/commen.css" media="all">
    <script>
        var base =  "${base}";
    </script>
</head>
<body>
<br>
<form class="layui-form " action="">
         <input type="hidden" id="id" name="id" value="${user.id!}" >
          <div class="layui-form-item">
              <label class="layui-form-label">账户名称</label>
              <div class="layui-input-block">
                  <input type="text" id="userName" name="userName" value="${user.userName!}"  autocomplete="off" placeholder="请输入账户名称"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">单位名称</label>
              <div class="layui-input-block">
                  <input type="text" id="companyName" name="companyName" value="${user.companyName!}"  autocomplete="off" placeholder="请输入单位名称"
                         class="layui-input">
              </div>
          </div>

          <div class="layui-form-item">
              <label class="layui-form-label">手机号</label>
              <div class="layui-input-block">
                  <input type="text" id="phone" name="phone" value="${user.phone!}"  autocomplete="off" placeholder="请输入手机号"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">密码</label>
              <div class="layui-input-block">
                  <input type="password" id="passWord" name="passWord" value="${user.passWord!}"  autocomplete="off" placeholder="请输入密码"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">重复密码</label>
              <div class="layui-input-block">
                  <input type="password" id="rePassWord" name="passWord" value="${user.passWord!}"  autocomplete="off" placeholder="请输入密码"
                         class="layui-input">
              </div>
          </div>



    <div align="center">
        <button type="button" class="layui-btn" id="submit">保存</button>
    </div>
</form>

<script src="${base}/static/win10/component/layui/layui.js?t=1"></script>
<script src="${base}/static/win10/js/jquery-1.8.3.min.js?t=1"></script>
<script>
    layui.use(['table','form', 'layer','element','transfer'], function() {
        var form = layui.form;
        var element = layui.element
                , layer = layui.layer;
        var table = layui.table;
        var transfer = layui.transfer;


        $("#submit").on("click",function () {
            var formDate = {
                         id:$("#id").val(),
                         userName:$("#userName").val(),
                         companyName:$("#companyName").val(),
                         phone:$("#phone").val(),
                           passWord:$("#passWord").val()
            }
            $.ajax({
                type: "POST",
                url: base+"/WeChatUser/user/admin/editUser",
                data: formDate,
                success: function (data) {
                    layer.msg(data.message)
                    if (data.code === 200) {
                        window.location.href=base+"/WeChatUser/user/admin/main.html"
                    } else {

                    }
                }
            });



        })







        function check(){
                   if($("#userName").val().length<1){
                       layer.msg("请输入账户名称");
                       return false;
                   }

                   if($("#companyName").val().length<1){
                       layer.msg("请输入单位名称");
                       return false;
                   }

                   if($("#phone").val().length<1){
                       layer.msg("请输入手机号");
                       return false;
                   }
                   if($("#passWord").val().length<1){
                       layer.msg("请输入密码");
                       return false;
                   }
                   if($("#passWord").val()!==$("#rePassWord").val()){
                       layer.msg("两次密码不一样");
                       return false;
                   }
        }
    });

</script>
</body>
</html>